#pragma once

#include "IEventListener.h"

#include "Menus\Button.h"
#include "Menus\UserInterface.h"

class Label;
class Picture;
class World;
class TimeManager;
class GameStateObject;
class CameraComponent;

namespace ZeEngine
{
    class Timer;
}

class GameStateUserInterface : public ButtonListener, public UserInterface, public IMouseListener, public IEventListener
{
private:
    enum UIState
    {
        eShowingNothingOnMouse,
        eShowingActivePictureOnMouse,
    };

public:
    GameStateUserInterface(ZeEngine::GUISystem& guiSystem, std::shared_ptr<GameStateObject> pGameStateObject);
    ~GameStateUserInterface();

    bool Update(ZeEngine::GameEngine& gameEngine);
    bool Init(ZeEngine::GameEngine& gameEngine);

    void Destroy(ZeEngine::GameEngine& gameEngine);

    //ButtonListener 
    virtual void OnButtonClicked(u32 id) override;

    //MouseListener
    virtual bool OnMouseMoved(const Vector2D<s32>& absolute, const Vector2D<s32>& relative) override;
    virtual bool OnMouseButtonPressed(const Vector2D<s32>& absolute, s32 button) override;
    virtual bool OnMouseButtonReleased(const Vector2D<s32>& absolute, s32 button) override;

    //IEventListener
    virtual bool HandleEvent(const Event& evt) override;

private:
    void FindClickedEntities(GameEngine& gameEngine, Vector2D<s32> mousePosition);
    void SetActivePictureOnMouse(const std::string& group, const std::string& image);

private:
    std::shared_ptr<GameStateObject> m_pGameStateObject;

    GameEngine*                      m_pGameEngine;
    Vector2D<u32>                    m_resolution;

    std::shared_ptr<Button> m_pFastForward;
    std::shared_ptr<Button> m_pFastBackward;
    std::shared_ptr<Button> m_pBtnReport;

    std::shared_ptr<Button> m_128Button;

    std::shared_ptr<Label>  m_pFPS;
    std::shared_ptr<Label>  m_pTime;

    std::shared_ptr<Picture> m_activePictureOnMouse;
    std::shared_ptr<Picture> m_reportPicture;

    //When we click entities
    std::unique_ptr<Timer>					m_clickTimer;
    u32										m_elapsedClickTime;
    Vector2D<s32>                           m_clickLocation;
    std::vector<Entity*>                    m_clickedEntities;

    //Store a pointer of the Camera Components
    CameraComponent*                        m_pGaulemCameraComponent;
    CameraComponent*                        m_pBaseCameraComponent;

    UIState                                 m_state;
};

